package cn.edu.nchu;

import cn.edu.nchu.entity.ProductModel;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;

public class TestJson {
    public static void main(String[] args) {
        String json = "{\"accessProtocol\":null,\"creationTime\":null,\"dataProtocol\":\"aaaaaaaa\",\"deviceType\":\"12312123\",\"id\":null,\"networkingType\":null,\"productId\":null,\"productName\":null,\"productType\":null}";
//        JSONObject jsonObject = JSONObject.parseObject(json);
        ProductModel productModel = new ProductModel();
        productModel.setDataProtocol("123123");
        productModel.setDeviceType("12312123");
        System.out.println(JSONObject.parseObject(json, ProductModel.class));

//        ProductModel productModel = jsonObject.toJavaObject(ProductModel.class);
        System.out.println(JSONObject.toJSONString(productModel, SerializerFeature.WriteMapNullValue));

    }
}
